package com.hange.ymcc.controller;


import com.hange.ymcc.doc.CourseDoc;
import com.hange.ymcc.dto.SearchDto;
import com.hange.ymcc.result.JSONResult;
import com.hange.ymcc.service.ESCourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping
public class ESCourseController {

    @Autowired
    private ESCourseService esCourseService;

    @PostMapping("/esCourse/save")
    //@PreAuthorize("hasAnyAuthority('esCourse:save')")
    public JSONResult save(@RequestBody CourseDoc courseDoc) {
        esCourseService.save(courseDoc);
        return JSONResult.success();
    }

    @PostMapping("/course/search")
    public JSONResult search(@RequestBody SearchDto searchDto) {
        return JSONResult.success(esCourseService.search(searchDto));
    }
}
